package com.tanhua.server.controller;

import com.tanhua.autoconfig.templates.OssTemplate;
import com.tanhua.model.vo.VoiceVo;
import com.tanhua.server.service.PeachblossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 桃花传音
 */
@RestController
@RequestMapping("/peachblossom")
public class PeachblossomController {

    @Autowired
    private PeachblossomService peachblossomService;

    /**
     * 桃花传音-发送语音（学生实战
     * POST
     * Body:
     * soundFile：语音文件
     */
    @PostMapping
    public ResponseEntity peachblossom(MultipartFile soundFile) throws IOException {
        peachblossomService.peachblossom(soundFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 桃花传音-接收语音（学生实战）
     * GET/peachblossom
     * 请求：
     * 返回：
     * VoiceVo
     */
    @GetMapping
    public ResponseEntity peachblossom() {
        VoiceVo vo = peachblossomService.peachblossom();
        return ResponseEntity.ok(vo);
    }
}
